const app = getApp()

let pageNo = 1;

Page({
  data: {
    imgUrls: [{
        selected: true,
        photo: 'http://39.104.123.0/image/time1.jpeg',
        stype: true
      },
      {
        selected: false,
        photo: 'http://39.104.123.0/image/time3.jpeg',
        stype: true
      },
      {
        selected: false,
        photo: 'http://39.104.123.0/image/time4.jpeg',
        stype: true
      },
      {
        selected: false,
        photo: 'http://39.104.123.0/image/time2.jpeg',
        stype: true
      },

    ],
    matchingList: [],
    orderList: [],
    indicatorDots: true,
    autoplay: true,
    interval: 5000,
    duration: 1000,
    printOrder: false,


    pageLoad: false,
  },

  collectGoods: function() {
    var that = this;
    wx.showModal({
      title: '提示',
      content: '是否确认已收到货',
      success: function(res) {
        if (res.confirm) {
          that.setData({
            printOrder: true,
          })         
          wx.request({
            url: app.data.baseUrl + '/transaction/DeliveryNoteMgrAction!deliverSure',
            method: 'get',
            data: {
              'deliveryNote.id': that.data.deliveryNoteid,
              'deliveryNote.deliver_sure_descr': that.data.mark
            },
            header: app.globalData.header,
            success: function(res) {
              console.log(res)
              if (res.data.statusCode=='200'){
                var msg = res.data.msg;
                wx.showToast({
                  title: msg,
                })
              } else {
                wx.showToast({
                  icon:'loading',
                  title: '收货失败',
                })}
              console.log(res)
             
            },
            fail: function(e) {
              wx.showToast({
                title: '网络异常！',
                duration: 2000
              });
            },
          })
        } else { //这里是点击了取消以后        
        }
      }
    })
  },
  onLoad: function(e) {
    var that = this;
    if (app.globalData.isGetCookie == '') {
      setTimeout(function() {
        that.onLoad();
      }, 1000)
    } else {
      that.init();
    }
  },
  init: function() {
    var that = this
    wx.request({
      url: app.data.baseUrl + '/transaction/DeliveryNoteMgrAction!list',
      method: 'post',
      data: {},
      header: app.globalData.header,
      success: function(res) {
        var rows = res.data.rows;
        console.log('init')
        console.log(res);
        that.setData({
          matchingList: rows,
        });
        that.getorder(rows[0].id)
      },
      fail: function(e) {
        wx.showToast({
          title: '网络异常！',
          duration: 2000
        });
      },
    })
  },
  getorder: function(id) {
    var that = this
    console.log(id)
    wx.request({
      url: app.data.baseUrl + '/transaction/DeliveryNoteMgrAction!listOrderForm',
      method: 'get',
      data: {
        'deliveryNote.id': id
      },
      header: app.globalData.header,
      success: function(res) {
        var rows = res.data.rows;
        console.log(res);

        that.setData({
          orderList: rows,
        });
      },
      fail: function(e) {
        wx.showToast({
          title: '网络异常！',
          duration: 2000
        });
      },
    })
  }




})